package com.deli.springboot.service;

import com.deli.springboot.mapper.BookMapper;
import com.deli.springboot.entity.Book;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

   @Autowired
   private BookMapper bookMapper;


    @Override
    public List<Book> findByExample(Book book) {
        //书名/条形码
        //List<Book> brands = bookRepository.selectByExample(book);
        if (StringUtils.isNotBlank(book.getbName())){
            book.setbName("%"+book.getbName()+"%");
        }
        //TODO 分页
        List<Book> books = bookMapper.selectByExample(book);
        return books;
    }

    @Override
    public Integer add(Book book) {
        //int result = bookRepository.add(book);
        int result = bookMapper.add(book);
        return result;
    }
}
